var menu_dropdowns=$('.Hui-aside')[0].children;
$('#titles1').children().click(function(){
	$(".current").removeClass('current');
	this.classList.add('current');
});
$('.titles').each(function(index,element){
	this.onclick=function(){
		titleClick(index,element);
	};
});
function titleClick(index,element){
	$(".current").removeClass('current');
	element.classList.add('current');
	$('.Hui-aside:visible')[0].classList.add('hidden');
	$('.Hui-aside')[index].classList.remove('hidden');
}
$('.menu_subject li').find('a').on('click',function(){
	showScales($(this));
})
$('.menu_subject1').find('a').on('click',function(){
	showScales($(this));
})
function showScales(obj){
	//console.log(obj);
	$('section').html('');
	var category_relation_id=obj.attr('name');
	var type=$('.current').attr("name");
	console.log("type:"+type+"*******category_relation_id"+category_relation_id)
	var url="./StudentMainServlet";
	$.ajax({
		"data":"category_relation_id="+category_relation_id+"&type="+type,
		"url":url,
		"type":"POST",
		"success":function(result){
			var json=JSON.parse(result);
			var text;
			for(var s in json){
				text="<a class='button-1' name='"+json[s].scale_id+"'><p>"+json[s].name+"</p><p>时间："+json[s].test_time+"</p><p>创建人："+json[s].manager_name+"</p><p>总分："+json[s].total_score+"</p></a>"
				$('section').append(text);
			}
			initScale_btn();
		},
		"error":function(result){
			alert('请求超时，请重新登陆！');
		}
	})
}
function initScale_btn(){
	$('.button-1').on('click',function(){
		var scale_id=$(this).attr('name');
		$.cookie("scale_id",scale_id);
		url="./student/testpage.jsp";
		location.href=url;
	})
}
/*$.cookie("like", value, { 
  　　path: "/", expiress: 7 
  })*/
